package ch.fhnw.qualiscan.api.output;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import ch.fhnw.qualiscan.Config;
import ch.fhnw.qualiscan.core.db.pojos.BestPractice;

@XmlRootElement(name = "bestpractice")
@XmlType(propOrder = { "link", "id", "domain", "survey", "user", "visibility", "title", "text"})
public class BestPracticeOutput {
	
	BestPractice bp;
	
	public BestPracticeOutput() {
		
	}
	
	public BestPracticeOutput(BestPractice bp) {
		this.bp = bp;
	}

	@XmlElement
	public String getLink() {
		return Config.API_URL + "bestpractices/" + this.bp.getId();
	}
	
    @XmlElement
    public int getId() {
        return this.bp.getId();
    }

    @XmlElement
    public String getTitle() {
        return this.bp.getTitle();
    }

    @XmlElement
    public String getText() {
        return this.bp.getBestpractice();
    }
    
    @XmlElement
    public int getDomain() {
        return this.bp.getDomain().getId();
    }
    
    @XmlElement
    public int getVisibility() {
    	// 0 = public, 1 = private
        return this.bp.getPublicpost();
    }
    
    @XmlElement
    public int getSurvey() {
        return this.bp.getSurvey().getId();
    }
    
    @XmlElement
    public int getUser() {
        return this.bp.getUser().getId();
    }
	
}
